package com.makejl.handler;

import java.util.Iterator;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;

import com.makejl.domain.LoginUser;
import com.makejl.framework.Handler;
import com.makejl.util.InformationMessage;

/**
 * 
 * @author Beni
 * 
 */
public class RegisterHandler extends Handler {

	private static final long serialVersionUID = 3982905096731705254L;

	private LoginUser loginUser = new LoginUser();

	public RegisterHandler() {
		super();
		prepare();
	}

	public void prepare() {
		getMessage();
	}

	public void register() {
		getMessage();
		loginUser.setUsermail("abc@163.com");
	}

	public void onblurMail(){
		
		if(loginUser.getUsermail()==null ||loginUser.getUsermail().indexOf("@")==-1){
			setMessage(this.getClass(), new InformationMessage("INF_VHD_0003", new Object [] {"contentForm:inputMail"}));
		}
	}
	private void getMessage() {
		Iterator<FacesMessage> it = FacesContext.getCurrentInstance().getMessages();

		while (it.hasNext()) {
			FacesMessage fm=(FacesMessage)it.next();
			System.out.println("detail: "+fm.getDetail());
			System.out.println("summary: "+fm.getSummary());
		}
	}

	public LoginUser getLoginUser() {
		return loginUser;
	}

	public void setLoginUser(LoginUser loginUser) {
		this.loginUser = loginUser;
	}

}
